package com.hua.api.modules.order.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import org.hibernate.annotations.Formula;

import javax.persistence.*;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.math.BigDecimal;
import java.io.Serializable;
import java.util.Date;


@Entity
@Data
@Table(name="order_bid_item")
public class OrderBidItem implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Integer id;

    @Column(name = "order_bid_id")
    private Integer orderBidId;

    @Column(name = "distance")
    @ApiModelProperty(value = "配送距离")
    private Integer distance;

    @Column(name = "shop_id")
    @ApiModelProperty(value = "推送店铺id")
    private Integer shopId;

    @Column(name = "bid_price")
    @ApiModelProperty(value = "出价")
    private Double bidPrice;

    @Column(name = "created_time")
    @ApiModelProperty(value = "创建时间")
    private Date createdTime;

    @Column(name = "bid_time")
    @ApiModelProperty(value = "出价时间")
    private Date bidTime;

    @Column(name = "modify_time")
    private Integer modifyTime;

    @Column(name = "state")
    @ApiModelProperty(value = "状态 推送 阅读 出价 接单")
    private Integer state;

    @Formula("( select s.user_id from shop_info s where s.id=shop_id )")
    private Integer userId;

    @Formula("( select s.phone_number from shop_info s where s.id=shop_id )")
    private String phoneNumber;


    public void copy(OrderBidItem source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}